package severlet;

import bean.LeaveReturn;
import dao.LeaveReturnDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

@WebServlet(name = "AdminLeavereturnServlet", value = "/AdminLeavereturnServlet")
public class AdminLeavereturnServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("utf-8"); // 设置编码格式
        request.setCharacterEncoding("utf-8");

        //调用dao层查询
        LeaveReturnDao leaveReturnDao=new LeaveReturnDao();
        //查询
        ArrayList<LeaveReturn> allLeavareturn = leaveReturnDao.getAllLeavareturn();
        //存入session
        request.getSession().setAttribute("adminLeavereturn",allLeavareturn);
        //请求转发
        request.getRequestDispatcher("admin_leavereturn.jsp").forward(request,response);
    }
}
